
#ifndef   __SIMPHONY_CDR 		  /* CALL DATA RECORD */
#define   __SIMPHONY_CDR

/* 
======= Storage CDR format: =========
 1. IMSI - 			(all number) 7.5
 2. Date - 			dd.mm.yy     2    
 3. Time - 			hh.mm.ss     2
 4. Phone Number	xxxxxxxxxx   10 
 5. Duration		sec          2 
===================================== 
                                 23.5 => 24; 
  ======== Date =========		  ======== Time =========

  4 Bytes:		ss.  mm.   hh             dd.  mm.   yy
    Bits:      0-4  5-10 11-15   Bits:	 16-20 21-24 25-31				
*/

#define   CDR_COUNT_MAX				1000

#define   IMSI_SIZE					8
#define   PHONE_NUMBER_SIZE		8
#define   CDR_SIZE					( IMSI_SIZE + PHONE_NUMBER_SIZE + 6 ) /* 22 */

/* DATE */
#define   MONTH_SHIFT				5
#define   YEAR_SHIFT					9
/* TIME */
#define   MINUTES_SHIFT				5
#define   SECOND_SHIFT				11

typedef struct 
{
		unsigned char IMSI[IMSI_SIZE]; 										/* BCD FORMAT */
		unsigned char Destination_PhoneNumber[PHONE_NUMBER_SIZE];	/* BCD FORMAT */
		unsigned long DateTime;
		unsigned int  Duration; 	// MSB if '1', then INTERNAL IMSI, if '0' - EXTERNAL /* sec */
}CDR;


extern unsigned int CDR_Pointer;

void CDR_Init ( void );
unsigned char CDR_Save ( CDR*  );
unsigned int CDR_AddressToIndex( unsigned int Address );
unsigned int CDR_IndexToAddress ( unsigned int Index );

#endif

